package com.broada.apm.logic;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.broada.apm.entity.NoticeCommandException;
import com.broada.apm.indicator.api.ApmClientFactory;
import com.broada.apm.indicator.api.common.ApmDataIndicatorException;
import com.broada.apm.service.internal.IndicatorService;
import com.broada.apm.service.internal.impl.IndicatorServiceImpl;
import com.broada.apm.utils.ExceptionUtils;

/**
 * @ClassName: ClearProtocolRelation
 * @Description:
 * @author Hety
 * @date 2015年6月8日 下午4:02:19
 */
public class ClearProtocolRelation{
	private Logger LOG = LoggerFactory.getLogger(ClearProtocolRelation.class);
	
	IndicatorService indicatorService = new IndicatorServiceImpl();

	public void clear() {
		try {
			// 删除所有不合法数据(关系的来源或目的service为空的数据)
			ApmClientFactory.getApmClient().getRelationService().deleteValidRelation();
			indicatorService.NoticeCommand("reload", "disresource");
			LOG.info("ClearProtocolRelation success !");
		} catch (NoticeCommandException e) {
			ExceptionUtils.error(LOG, "通知indicator失败！", e);
		}
	}

	public static void main(String[] args) throws ApmDataIndicatorException {
		ClearProtocolRelation clear = new ClearProtocolRelation();
		clear.clear();
	}
}
